<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  const pending ='pending'
  const FULFILLED ='FULFILLED'
  const REJECTED = 'REJECTED';
  class Promise{
    constructor(executor) {
      this.status ='pending'
      this.value = undefined
      this.reason = undefined
      let resolve =(value)=>{
        if(this.status == pending){
          this.status = FULFILLED;
          this.value = value
        }
      }
      let reject =(reason)=>{
        if(this.status == pending){
          this.status = REJECTED;
          this.reason = reason;
        }
      }


      try {
        executor(resolve,reject)
      }catch (e) {
        reject(e)
      }
    }
  }

</script>
</body>
</html>
